<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ page import="com.gouwudai.gobbs.pojo.TbbsAffiche,com.gouwudai.gobbs.pojo.TbbsSysInfo,com.fredck.FCKeditor.*"%>
<%@ include file="../../common/common.jsp" %>
<%@ include file="master_pass.jsp" %>
<%
Integer affId = Utility.parseInt(request.getParameter("affId"));

IAfficheService afficheService = (IAfficheService)BeanManager.getBean("afficheService");
TbbsAffiche obj = afficheService.load(affId);
%>
<HTML>
<HEAD>
<title>编辑公告信息</title>
<%@ include file="../../common/meta.inc" %>
<link href="css.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="javascript" SRC="${pageContext.request.contextPath}/scripts/common-validator.js"></SCRIPT>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
<script language="javascript">
var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);
function doSubmit() {

	form = document.theform;
	
	if(!validateForm(form))
		return;
		
		
    var obj = {};
	obj[Buffalo.BOCLASS] = "com.gouwudai.gobbs.pojo.TbbsAffiche";
	obj.affId=<%=affId%>;
	
	obj.classId=parseInt($F('classId'));
	obj.validDays=parseInt($F('validDays'));
	obj.title=$F('title');
	obj.content=FCKeditorAPI.GetInstance('content').GetXHTML(true);

    buffalo.remoteCall("afficheServiceAjaxService.update",[obj], function(reply) {
        ajaxSubmit(reply.getResult(),"保存成功！","back");
    });
}

function validateForm(form)
{
    if(!sl_check(form.title,"公告主题",50,1)) return false;
    if(!sl_checkIntValue(form.validDays,"有效期",365,0)) return false;
    return sl_confirmUpdate();
}

</script>
</HEAD>
<BODY leftMargin=0 topMargin=0 rightmargin="0" bottommargin="0">
<table width="99%" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#e6e6e6">
  <tr>
    <td align="center"><strong>编辑公告信息</strong></td>
  </tr>
</table>
<form name="theform" method="post" action="">
						<table width="99%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#e6e6e6">								
							<tr bgcolor="#f6f6f6">
								<td width="15%" align="right">所属分类/版面:</td>
								<td width="85%">
								<select size="1" name="classId" id="classId" onkeydown="javascript:nextKeyPress(this)">
									<option value="0">&lt;首页&gt;</option>
									<option value="-1" <%if(obj.getClassId().intValue()==-1) out.print("selected"); %>>&lt;全部版面&gt;</option>
									<%=Arguments.getAllClassOptions(obj.getClassId())%>
								</select>
								</td>
							</tr>													
							<tr bgcolor="#f6f6f6">
								<td align="right">公告主题:</td>
								<td><input type="text" name="title" id="title" value="<%=obj.getTitle() %>" onkeydown="javascript:nextKeyPress(this)" size="20"></td>
							</tr>	
							<tr bgcolor="#f6f6f6">
								<td align="right">有效期:</td>
								<td><input type="text" name="validDays" id="validDays" value="<%=obj.getValidDays() %>" onkeydown="javascript:nextKeyPress(this)" size="4" maxlength="4">天<span class="remark">（0为长期有效）</span></td>
							</tr>
							<tr bgcolor="#f6f6f6">
								<td align="right">内容:</td>
								<td>
<%
FCKeditor oFCKeditor ;
oFCKeditor = new FCKeditor( request, "content" ) ;
oFCKeditor.setBasePath( contextPath+"/fckeditor/" ) ;
oFCKeditor.setValue( obj.getContent() );
oFCKeditor.setHeight("400");
FCKeditorConfigurations fckConfig = oFCKeditor.getConfig();
fckConfig.put("LinkBrowser","true");//超链浏览
fckConfig.put("ImageBrowser","true");//图片浏览
fckConfig.put("FlashBrowser","true");//FLASH浏览
fckConfig.put("LinkUpload","true");//文件上传
fckConfig.put("ImageUpload","true");//图片上传
fckConfig.put("FlashUpload","true");//FLASH上传
oFCKeditor.setConfig(fckConfig);
out.println( oFCKeditor.create() ) ;
%>	
								</td>
							</tr>																																				
						</table>
						<table border="0" width="100%">
							<tr>
								<td align="right">
								<button class="btn" accessKey=s id="btnSave" name="btnSave" onclick="javascript:doSubmit();">保存(<u>S</u>)</button>
								&nbsp;&nbsp;
								<button class="btn" accessKey=c id="btnCancel" name="btnCancel" onclick="javascript:history.back();">取消(<u>C</u>)</button>
								&nbsp;&nbsp;								
								</td>
							</tr>
						</table>
</form>
</BODY>
</HTML>

